package com.cn.wanxi.service;

import com.cn.wanxi.IO.FileModelIO;
import com.cn.wanxi.IOModel.PictureRotationIOModel;
import com.cn.wanxi.model.PictureRotationModel;
import com.cn.wanxi.util.IOUtil;

import java.util.List;

public class PictureRotationService {
    public List<PictureRotationModel> getPictures(){
        FileModelIO.writeData(IOUtil.PICTUREROTATIONIOMODELPATH.getPath(),new PictureRotationIOModel().toString());
        String result = FileModelIO.readData(IOUtil.PICTUREROTATIONIOMODELPATH.getPath());
        result = result.substring(result.indexOf("[")+1,result.lastIndexOf("]"));
        String[] hrefs = result.split(",");
        PictureRotationModel pictureRotationModel = new PictureRotationModel();
        for (int i = 0; i < hrefs.length; i++) {
            PictureRotationModel picture = new PictureRotationModel();
            picture.setHref(hrefs[i].trim());
            pictureRotationModel.list.add(picture);
            System.out.println(hrefs[i].trim());
        }
        return pictureRotationModel.list;
    }

    public static void main(String[] args) {
        new PictureRotationService().getPictures();
    }
}
